package main

import (
	"fmt"

	"github.com/gin-gonic/gin"
)

func printf(format string, a ...interface{}) (n int, err error) {
	format += "\n"
	n, err = fmt.Printf(format, a...)
	return
}

func print(a ...interface{}) (n int, err error) {
	n, err = fmt.Println(a...)
	return
}

func main() {
	router := gin.Default()
	router.GET("/index", func(context *gin.Context) {
		name := context.DefaultQuery("name", "abc")
		context.Writer.Write([]byte("Hiiii, " + name))
	})

	router.POST("/index", func(context *gin.Context) {
		// gin.FullPath()
		var user User
		context.BindJSON(&user)

		context.String(200, "%s 年龄增长了：{%d}", user.Name, user.Age)
	})

	router.Run(":9999")
}

type User struct {
	Name string `form:"name"`
	Age  int    `form:"age"`
}
